package com.example.userclient.activity

import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.userclient.Main.ClientInfoHolder
import com.example.userclient.R
import com.example.userclient.adapter.AddBookListAdapter
import com.example.userclient.databinding.ActivityUserAddBooksBinding

class UserSaleBooksActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val bind = DataBindingUtil.setContentView<ActivityUserAddBooksBinding>(this, R.layout.activity_user_add_books)

        for (i in ClientInfoHolder.userAddBook!!){
            Log.i("UserSaleBooksActivity", i.addBook.bookOwner)
        }
        AddBookListAdapter.dataSet = ClientInfoHolder.userAddBook?.toTypedArray()
        bind.userAddBooksList.adapter = AddBookListAdapter
        bind!!.userAddBooksList.layoutManager = LinearLayoutManager(this,
            RecyclerView.VERTICAL,false)

        bind.addBack.setOnClickListener{
            this.finish()
        }
    }

    companion object{
        fun actionStart(context: Context){
            val intent = Intent(context, UserSaleBooksActivity::class.java)
            context.startActivity(intent)
        }
    }
}